using System;
using System.ComponentModel.Composition;
using Windy.Transformations;
using System.Collections.Generic;
using Windy.TurtleDrawing;

namespace Windy.DragonCurve.Models.Schemes
{
    /// <summary>
    /// 1st iteration: R
    /// 2nd iteration: R R L
    /// 3rd iteration: R R L R R L L
    /// 4th iteration: R R L R R L L R R R L L R L L.
    /// </summary>
    [Export(typeof(DragonCurveScheme))]
    public class UnfoldDragonScheme : DragonCurveScheme
    {
        public UnfoldDragonScheme()
        {
            this.SetupName("Unfold Dragon")
                .SetupInitialSymbols(Symbols.Plus)
                .SetupCurveRules(
                    new ExpandTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.Plus,
                        Symbols.Plus, Symbols.Plus, Symbols.Minus),
                    new ReplaceTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.Minus, Symbols.Minus))
                .SetupPlotRules(
                    new ExpandTransformRule<Symbols, Symbols, Action<DragonCurve, Turtle>>(Symbols.Plus,
                        DrawActions.StepForward, DrawActions.TurnRight),
                    new ExpandTransformRule<Symbols, Symbols, Action<DragonCurve, Turtle>>(Symbols.Minus,
                        DrawActions.StepForward, DrawActions.TurnLeft))
                .SetupStepAngelDegree(90);
        }
    }
}
